<?php

/**
 * Tournament filter form base class.
 *
 * @package    makethetouch
 * @subpackage filter
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseTournamentFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'description'            => new sfWidgetFormFilterInput(),
      'expected_referee_level' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'), 'add_empty' => true)),
      'organisator'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Person'), 'add_empty' => true)),
      'referee_director'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Person_2'), 'add_empty' => true)),
      'venue'                  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => true)),
      'begin_date'             => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'end_date'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'final_function_address' => new sfWidgetFormFilterInput(),
      'team_fee'               => new sfWidgetFormFilterInput(),
      'player_fee'             => new sfWidgetFormFilterInput(),
      'national_team'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'description'            => new sfValidatorPass(array('required' => false)),
      'expected_referee_level' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('RefereeLevel'), 'column' => 'color')),
      'organisator'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Person'), 'column' => 'login')),
      'referee_director'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Person_2'), 'column' => 'login')),
      'venue'                  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Address'), 'column' => 'idaddress')),
      'begin_date'             => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'end_date'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'final_function_address' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'team_fee'               => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'player_fee'             => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'national_team'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('tournament_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Tournament';
  }

  public function getFields()
  {
    return array(
      'name'                   => 'Text',
      'description'            => 'Text',
      'expected_referee_level' => 'ForeignKey',
      'organisator'            => 'ForeignKey',
      'referee_director'       => 'ForeignKey',
      'venue'                  => 'ForeignKey',
      'begin_date'             => 'Date',
      'end_date'               => 'Date',
      'final_function_address' => 'Number',
      'team_fee'               => 'Number',
      'player_fee'             => 'Number',
      'national_team'          => 'Number',
    );
  }
}
